<template>
    <div class="header">
        <div>
            <span>ToDoList</span>
            <input type="text" placeholder="添加toDo" @keydown.enter="addTask">
        </div>
    </div>
</template>

<script>
import { useStore } from 'vuex'
export default {
    setup() {
        let store = useStore()
        function addTask(e) {
            store.commit('addTask', e.target.value)
            e.target.value = ''
        }

        return {
            addTask
        }
    }
}
</script>

<style scoped lang="scss">
.header {
    background-color: rgba(47,47,47,0.98);
    div {
        width: 800px;
        height: 50px;
        display: flex;
        margin: 0 auto;
        justify-content: space-between;
        align-items: center;
        span {
        font-size: 28px;
        font-weight: bold;
        color: #fff;}
        input {
        width: 400px;
        border: none;
        outline: none;
        border-radius: 6px;
        height: 30px;
        padding-left: 10px;}
    }
}
</style>